package org.dromara.system.business.developer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import kotlin.jvm.internal.Lambda;
import org.dromara.system.business.developer.entity.PlanDeveloper;
import org.dromara.system.business.developer.dao.PlanDeveloperDao;
import org.dromara.system.business.developer.service.PlanDeveloperService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;



/**
 * (PlanDeveloper)表服务实现类
 *
 * @author makejava
 * @since 2025-02-07 16:36:23
 */
@Service("planDeveloperService")
public class PlanDeveloperServiceImpl implements PlanDeveloperService {
    @Resource
    private PlanDeveloperDao planDeveloperDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PlanDeveloper queryById(Long id) {
        return this.planDeveloperDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param planDeveloper 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<PlanDeveloper> queryByPage(PlanDeveloper planDeveloper, PageRequest pageRequest) {

        LambdaQueryWrapper<PlanDeveloper> wrapper = new LambdaQueryWrapper<>();
        long total = this.planDeveloperDao.count(planDeveloper);
        return new PageImpl<>(this.planDeveloperDao.queryAllByLimit(planDeveloper, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param planDeveloper 实例对象
     * @return 实例对象
     */
    @Override
    public PlanDeveloper insert(PlanDeveloper planDeveloper) {
        this.planDeveloperDao.insert(planDeveloper);
        return planDeveloper;
    }

    /**
     * 修改数据
     *
     * @param planDeveloper 实例对象
     * @return 实例对象
     */
    @Override
    public PlanDeveloper update(PlanDeveloper planDeveloper) {
        this.planDeveloperDao.update(planDeveloper);
        return this.queryById(planDeveloper.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.planDeveloperDao.deleteById(id) > 0;
    }
}
